<style lang="scss">
  .toggle {
    cursor: pointer;
    margin: 20px;
  }
</style>

<template>
  <div class="row">
    <div class="toggle" @click="toggle">TOGGLE</div>

    <audio-recorder v-if="showRecorder"
      :upload-url="url+interviewId"
      filename="ninja"
      format="wav"
      :attempts="3"
      :time="2"
      :headers="headers"
      :before-recording="callback"
      :pause-recording="callback"
      :after-recording="callback"
      :select-record="callback"
      :before-upload="callback"
      :successful-upload="callback"
      :failed-upload="callback"
      :bit-rate="192"/>

    <audio-player    :src="mp3" v-if="!showRecorder"/>
    <el-button @click="endInterview">面试结束</el-button>
  </div>
</template>

<script>
  export default {
    name: 'app',
    data () {
      return {
          id:null,
         progress: 0,
         url:`http://localhost:8868/api/interview/Oss/imagefile/`,
        mp3: 'https://pinxix-service.oss-cn-beijing.aliyuncs.com/2021-24-31ninja.mp3',
        showRecorder: true,
        headers: {
          'X-Custom-Header': 'some data'
        },
        interviewId:null
      }
    },
    methods: {
      callback (msg) {
        console.debug('Event: ', msg)
      },
      toggle () {
        this.showRecorder = !this.showRecorder
      },
      endInterview(){
             this.$http({
              url: this.$http.adornUrl(`/interview/interviewclass/update`),
              method: 'post',
              data: this.$http.adornData({
                'id':this.id,
                'studentId':1,
                'tearcherId':1,
                'status':2,
                'resumeId':1,
                'invitationId':this.invitationId
              })
            }).then(({data}) => {
            })
          this.$router.push({path:'interview-interviewinvitation'})  
        },
    },
    mounted(){
        this.id = this.$route.query.id
        this.interviewId = this.$route.query.invitationId
    }
  }
</script>